package edu.nju.mutest.mutator;

import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.expr.*;
import edu.nju.mutest.util.CollectorUtil;
import edu.nju.mutest.visitor.collector.BinaryExprCollector;

import java.util.List;

import static com.github.javaparser.ast.expr.BinaryExpr.Operator.*;

public class ArithmeticOperatorReplacementMutator extends AbstractMutator{

    private final List<BinaryExpr.Operator> targetOps = List.of(
            PLUS, MINUS, MULTIPLY, DIVIDE, REMAINDER
    );

    public ArithmeticOperatorReplacementMutator(CompilationUnit cu) {
        super(cu);
    }

    @Override
    public List<CompilationUnit> mutate() {
        if (this.mutPoints == null)
            mutPoints = CollectorUtil.collect(new BinaryExprCollector(), this.origCU);

        for (Expression mp : mutPoints) {
            generateMutantsForBinaryExpr((BinaryExpr) mp, targetOps);
        }
        return mutants;
    }
}
